package com.zhongyu.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhongyu.pojo.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ChuKuMapper extends BaseMapper<Order> {
  /*  @Select("SELECT t1.*, t2.pro_Name,t3.username FROM smbms_order t1 JOIN smbms_provider t2 ON t1.provider_id=t2.id  JOIN smbms_user t3 ON t1.creator AND CHECKER AND purchaser AND stock_keeper=t3.id WHERE state=0 AND TYPE=2 ${ew.customSqlSegment} ")
    @ResultMap("providerRm")
    List<Order> findAll(Page page, @Param("ew") Wrapper wrapper);*/
    @Select("SELECT t1.*, t2.pro_Name,t3.username FROM smbms_order t1 JOIN smbms_provider t2 ON t1.provider_id=t2.id  JOIN smbms_user t3 ON t1.creator AND purchaser=t3.id WHERE state=0 AND TYPE=2")
    @ResultMap("providerRm")
    List<Order> findAll(Page page);

    @Select("SELECT t1.*, t2.pro_Name,t3.username FROM smbms_order t1 JOIN smbms_provider t2 ON t1.provider_id=t2.id  JOIN smbms_user t3 ON t1.creator=t3.id  where t1.id=#{id} ")
    @ResultMap("providerRm")
    List<Order> searchAll(Integer id);

    @Select("SELECT t1.id AS t2id, t2.* FROM smbms_order t1 JOIN smbms_order_detail t2 ON t1.id=t2.order_id WHERE order_id=#{order_id} ")
    @ResultMap("OderRm")
    List<Order> search(Integer id);
}
